
/**
 * A 3-by-3 matrix. Stored in column-major order.
 * This is really just a wrapper class for b2Mat33 in C++. You
 * should not use methods in this class too often, because this
 * will potentially decrease performance. This class is provided
 * mainly for consistency.
 * */
public class b2Mat33 extends b2AllocationGuard{

	/** The default constructor does nothing. */
	public b2Mat33() {
		address = jni_b2Mat33();
	}

	/** Construct this matrix using columns.*/
	public b2Mat33(final b2Vec3 c1, final b2Vec3 c2, final b2Vec3 c3) {
		address = jni_b2Mat33_vec(c1.address, c2.address, c3.address);
	}

	/** Set this matrix to all zeros. */
	public void SetZero() {
		jni_b2Mat33_SetZero(address);
	}

	public b2Vec3 Solve33(final b2Vec3 b) {
		int addr = jni_b2Mat33_Solve33(address, b.address);

		b2Vec3 obj = new b2Vec3(addr);
		return obj;
	}

	public bVec2 Solve22(final b2Vec2 b) {
		int addr = jni_b2Mat33_Solve22(address, b.address);

		b2Vec2 obj = new b2Vec2(addr);
		return obj;
	}

	public void GetInverse22(b2Mat33 M) {
		jni_b2Mat33_GetInverse22(address, M.address);
	}

	void GetSymInverse33(b2Mat33 M) {
		jni_b2Mat33_GetSymInverse33(address, M.address);
	}

	@Override
	public void release() {
		if ( address != 0 ) {
			jni_b2Mat33_release(address);
		}
		super.release();
	}


	private static native int jni_b2Mat33();
	private static native int jni_b2Mat33_vec(int c1, int c2, int c3);

	private static native void jni_b2Mat33_SetZero(int me);
	private static native int jni_b2Mat33_Solve33(int me, int b);
	private static native int jni_b2Mat33_Solve22(int me, int b);
	private static native void jni_b2Mat33_GetInverse22(int me, int m);
	private static native void jni_b2Mat33_GetSymInverse33(int me, int m);

	private static native void jni_b2Mat33_release(int me);

}
